home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / praf205e / kiss.doc < prev    next >
Text File  |  1995-04-01  |  25KB  |  555 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.                   The KISS TNC: A simple Host-to-TNC communications
  12.                                        protocol
  13.  
  14.  
  15.                                  Mike Chepponis, K3MC
  16.  
  17.                                    Phil Karn, KA9Q
  18.  
  19.  
  20.  
  21.                                        ABSTRACT
  22.  
  23.                      The KISS[1] TNC provides direct computer  to  TNC
  24.                 communication  using a simple protocol described here.
  25.                 Many TNCs now implement it, including the  TAPR  TNC-1
  26.                 and TNC-2 (and their clones), the venerable VADCG TNC,
  27.                 the AEA PK-232/PK-87 and all TNCs  in  the  Kantronics
  28.                 line.   KISS has quickly become the protocol of choice
  29.                 for TCP/IP operation and multi-connect BBS software.
  30.  
  31.  
  32.  
  33.            1.  Introduction
  34.  
  35.                 Standard TNC software was written with human users in mind;
  36.            unfortunately,  commands and responses well suited for human use
  37.            are ill-adapted for host computer use, and vice versa.  This  is
  38.            especially  true  for multi-user servers such as bulletin boards
  39.            which must  multiplex  data  from  several  network  connections
  40.            across  a  single  host/TNC  link.  In addition, experimentation
  41.            with new link level protocols is greatly hampered because  there
  42.            may  very well be no way at all to generate or receive frames in
  43.            the desired format without reprogramming the TNC.
  44.  
  45.                 The KISS TNC solves these problems by eliminating  as  much
  46.            as possible from the TNC software, giving the attached host com-
  47.            plete control over and access to the contents of the HDLC frames
  48.            transmitted  and  received over the air.  This is central to the
  49.            KISS philosophy: the host software should have control over  all
  50.            TNC functions at the lowest possible level.
  51.  
  52.                 The AX.25 protocol is removed entirely from the TNC, as are
  53.            all  command interpreters and the like.  The TNC simply converts
  54.            between synchronous HDLC, spoken on  the  full-  or  half-duplex
  55.            radio  channel,  and  a  special asynchronous, full duplex frame
  56.            "Keep It Simple, Stupid"
  57.  
  58.  
  59.  
  60.  
  61.                                     July 14, 1990
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.            format spoken on the host/TNC link.  Every frame received on the
  71.            HDLC  link  is  passed  intact  to  the  host  once  it has been
  72.            translated to the asynchronous  format;  likewise,  asynchronous
  73.            frames  from  the host are transmitted on the radio channel once
  74.            they have been converted to HDLC format.
  75.  
  76.                 Of course, this means that the bulk of  AX.25  (or  another
  77.            protocol)  must  now  be implemented on the host system. This is
  78.            acceptable, however, considering the greatly increased flexibil-
  79.            ity  and reduced overall complexity that comes from allowing the
  80.            protocol to reside on the same machine with the applications  to
  81.            which it is closely coupled.
  82.  
  83.                 It should be stressed that the KISS TNC was  intended  only
  84.            as  a  stopgap.   Ideally, host computers would have HDLC inter-
  85.            faces of their  own,  making  separate  TNCs  unnecessary.  [15]
  86.            Unfortunately,  HDLC  interfaces  are  rare,  although  they are
  87.            starting to appear for the  IBM  PC.   The  KISS  TNC  therefore
  88.            becomes  the  "next  best thing" to a real HDLC interface, since
  89.            the host computer only needs an ordinary asynchronous interface.
  90.  
  91.            2.  Asynchronous Frame Format
  92.  
  93.                 The "asynchronous packet protocol" spoken between the  host
  94.            and  TNC  is  very simple, since its only function is to delimit
  95.            frames. Each frame is both preceded and followed  by  a  special
  96.            FEND  (Frame  End) character, analogous to an HDLC flag.  No CRC
  97.            or checksum is provided.  In addition,  no  RS-232C  handshaking
  98.            signals are employed.
  99.  
  100.                 The special characters are:
  101.  
  102.  
  103.            Abbreviation            Description                    Hex value
  104.               FEND                 Frame  End                         C0  
  105.               FESC                 Frame  Escape                      DB 
  106.               TFEND                Transposed Frame End               DC 
  107.               TFESC                Transposed Frame Escape            DD
  108.  
  109.  
  110.                 The reason for both preceding and ending frames with  FENDs
  111.            is  to  improve  performance  when  there is noise on the asynch
  112.            line.  The FEND at the beginning of a  frame  serves  to  "flush
  113.            out"  any  accumulated garbage into a separate frame (which will
  114.            be discarded by the upper layer protocol) instead of sticking it
  115.            on  the  front of an otherwise good frame.  As with back-to-back
  116.            flags in HDLC, two FEND characters in a row should not be inter-
  117.            preted as delimiting an empty frame.
  118.  
  119.            3.  Transparency
  120.  
  121.                 Frames are sent in 8-bit binary; the asynchronous  link  is
  122.            set  to  8 data bits, 1 stop bit, and no parity.  If a FEND ever
  123.            appears in the data, it is translated into the two byte sequence
  124.            FESC  TFEND  (Frame Escape, Transposed Frame End).  Likewise, if
  125.            the FESC character ever appears in the user data, it is replaced
  126.  
  127.  
  128.  
  129.                                     July 14, 1990
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.            with  the two character sequence FESC TFESC (Frame Escape, Tran-
  139.            sposed Frame Escape).
  140.  
  141.                 As characters arrive at the receiver, they are appended  to
  142.            a  buffer  containing the current frame.  Receiving a FEND marks
  143.            the end of the current  frame.   Receipt  of  a  FESC  puts  the
  144.            receiver  into "escaped mode", causing the receiver to translate
  145.            a following TFESC or TFEND back to FESC or  FEND,  respectively,
  146.            before adding it to the receive buffer and leaving escaped mode.
  147.            Receipt of any character other than  TFESC  or  TFEND  while  in
  148.            escaped  mode is an error; no action is taken and frame assembly
  149.            continues.  A TFEND or TESC received while not in  escaped  mode
  150.            is treated as an ordinary data character.
  151.  
  152.                 This procedure may seem somewhat  complicated,  but  it  is
  153.            easy  to implement and recovers quickly from errors. In particu-
  154.            lar, the FEND character is never sent over the channel except as
  155.            an  actual end-of-frame indication. This ensures that any intact
  156.            frame (properly delimited by FEND  characters)  will  always  be
  157.            received  properly  regardless  of  the  starting  state  of the
  158.            receiver or corruption of the preceding frame.
  159.  
  160.                 This asynchronous framing protocol is identical  to  "SLIP"
  161.            (Serial Line IP), a popular method for sending ARPA IP datagrams
  162.            across asynchronous links. It could also form the  basis  of  an
  163.            asynchronous  amateur packet radio link protocol that avoids the
  164.            complexity of HDLC on slow speed channels.
  165.  
  166.            4.  Control of the KISS TNC
  167.  
  168.                 Each asynchronous data frame sent to the TNC  is  converted
  169.            back  into "pure" form and queued for transmission as a separate
  170.            HDLC frame.  Although removing the human interface and the AX.25
  171.            protocol  from the TNC makes most existing TNC commands unneces-
  172.            sary (i.e., they  become  host  functions),  the  TNC  is  still
  173.            responsible  for keying the transmitter's PTT line and deferring
  174.            to other activity on the radio channel. It is  therefore  neces-
  175.            sary  to  allow the host to control a few TNC parameters, namely
  176.            the transmitter keyup delay, the transmitter  persistence  vari-
  177.            ables and any special hardware that a particular TNC may have.
  178.  
  179.                 To distinguish between  command  and  data  frames  on  the
  180.            host/TNC link, the first byte of each asynchronous frame between
  181.            host and TNC is a "type" indicator.  This type indicator byte is
  182.            broken into two 4-bit nibbles so that the low-order nibble indi-
  183.            cates the command number (given in  the  table  below)  and  the
  184.            high-order  nibble indicates the port number for that particular
  185.            command.  In systems with only one HDLC port, it is  by  defini-
  186.            tion  Port  0.  In multi-port TNCs, the upper 4 bits of the type
  187.            indicator byte can specify one of up to sixteen ports.  The fol-
  188.            lowing commands are defined in frames to the TNC  (the "Command"
  189.            field is in hexadecimal):
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                     July 14, 1990
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.            Command        Function         Comments  
  205.               0           Data frame       The  rest  of the frame is data to
  206.                                            be sent on the HDLC channel.   
  207.  
  208.               1           TXDELAY          The next  byte  is  the  transmitter
  209.                                            keyup  delay  in  10 ms units.  
  210.                                       The default start-up value is 50
  211.                                            (i.e., 500 ms). 
  212.  
  213.               2           P                The next byte  is  the  persistence
  214.                                            parameter,  p, scaled to the range 
  215.                                            0 - 255 with the following
  216.                                            formula:
  217.  
  218.                                                     P = p * 256 - 1 
  219.  
  220.                                            The  default  value  is  P  =  63  
  221.                                            (i.e.,  p  =  0.25).  
  222.  
  223.               3           SlotTime         The next byte is the slot interval 
  224.                                            in 10 ms units.
  225.                                            The default is 10 (i.e., 100ms). 
  226.  
  227.               4           TXtail           The next byte is the time to hold 
  228.                                            up the TX after the FCS has been 
  229.                                            sent, in 10 ms units.  This command
  230.                                            is obsolete, and is included  here 
  231.                                            only for  compatibility  with  some
  232.                                            existing  implementations.  
  233.  
  234.               5          FullDuplex        The next byte is 0 for half duplex,
  235.                                            nonzero  for full  duplex.  
  236.                                            The  default  is  0  
  237.                                            (i.e.,  half  duplex).  
  238.  
  239.               6          SetHardware       Specific for each TNC.  In the 
  240.                                            TNC-1, this command  sets  the 
  241.                                            modem speed.  Other implementations
  242.                                            may use this function  for   other
  243.                                            hardware-specific   functions.  
  244.     
  245.               FF         Return            Exit KISS and return control to a 
  246.                                            higher-level program. This is useful
  247.                                            only when KISS is  incorporated  
  248.                                            into  the TNC along with other 
  249.                                            applications.  
  250.  
  251.  
  252.                 The following types are defined in frames to the host:
  253.  
  254.            Type            Function        Comments  
  255.     
  256.              0                 Data frame       Rest of frame is data from
  257.                                                 the HDLC channel.
  258.  
  259.  
  260.                 No other types are defined; in particular, there is no pro-
  261.            vision for acknowledging data or command frames sent to the TNC.
  262.            KISS implementations must ignore any unsupported command  types.
  263.            All  KISS implementations must implement commands 0,1,2,3 and 5;
  264.            the others are optional.
  265.  
  266.            5.  Buffer and Packet Size Limits
  267.  
  268.                 One of the things that makes the KISS  TNC  simple  is  the
  269.            deliberate lack of TNC/host flow control. The host computers run
  270.            a higher level protocol (typically TCP, but AX.25  in  the  con-
  271.            nected  mode  also  qualifies)  that  handles flow control on an
  272.            end-to-end basis.  Ideally,  the  TNC  would  always  have  more
  273.            buffer  memory  than  the sum of all the flow control windows of
  274.            all of the logical connections using it  at  that  moment.  This
  275.            would  allow  for the worst case (i.e., all users sending simul-
  276.            taneously).  In practice, however, many (if not most) user  con-
  277.            nections are idle for long periods of time, so buffer memory may
  278.            be safely "overbooked".  When the occasional "bump" occurs,  the
  279.            TNC  must  drop  the  packet gracefully, i.e., ignore it without
  280.            crashing or losing packets already  queued.   The  higher  level
  281.            protocol   is   expected   to   recover  by  "backing  off"  and
  282.  
  283.  
  284.  
  285.                                     July 14, 1990
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.            retransmitting the packet at a later time, just as it does when-
  295.            ever  a  packet is lost in the network for any other reason.  As
  296.            long as this occurs infrequently, the performance degradation is
  297.            slight;  therefore the TNC should provide as much packet buffer-
  298.            ing as possible, limited only by available RAM.
  299.  
  300.                 Individual packets at  least  1024  bytes  long  should  be
  301.            allowed.   As  with  buffer  queues,  it  is recommended that no
  302.            artificial limits be placed on packet size.   For  example,  the
  303.            K3MC  code  running  on  a  TNC-2  with  32K of RAM can send and
  304.            receive 30K byte packets, although  this  is  admittedly  rather
  305.            extreme.   Large  packets reduce protocol overhead on good chan-
  306.            nels. They are essential for good performance when operating  on
  307.            high speed modems such as the new WA4DSY 56 kbps design.
  308.  
  309.  
  310.            6.  Persistence
  311.  
  312.                 The P and SlotTime parameters are used  to  implement  true
  313.            p-persistent CSMA.  This works as follows:
  314.  
  315.                 Whenever the host queues data  for  transmission,  the  TNC
  316.            begins  monitoring  the carrier detect signal from the modem. It
  317.            waits indefinitely for this signal  to  go  inactive.  When  the
  318.            channel  clears, the TNC generates a random number between 0 and
  319.            1.[2] If this number is less than or equal to the parameter p,
  320.            the  TNC  keys the transmitter, waits .01 * TXDELAY seconds, and
  321.            transmits all queued frames. The TNC then unkeys the transmitter
  322.            and  goes  back  to  the  idle  state.   If the random number is
  323.            greater than p, the TNC delays  .01  *  SlotTime  seconds  and
  324.            repeats the procedure beginning with the sampling of the carrier
  325.            detect signal. (If the carrier detect signal has gone active  in
  326.            the  meantime,  the  TNC again waits for it to clear before con-
  327.            tinuing).  Note that p = 1 means  "transmit  as  soon  as  the
  328.            channel clears"; in this case the p-persistence algorithm degen-
  329.            erates into the 1-persistent CSMA generally used by conventional
  330.            AX.25 TNCs.
  331.  
  332.                 p-persistence causes the TNC to wait for an  exponentially-
  333.            distributed  random  interval after sensing that the channel has
  334.            gone clear before attempting to transmit. With proper tuning  of
  335.            the  parameters  p and SlotTime, several stations with traffic
  336.            to send are much less likely to collide  with  each  other  when
  337.            they  all see the channel go clear.  One transmits first and the
  338.            others see it in time to prevent a collision,  and  the  channel
  339.            To conform to the literature, here p  takes  on values between 0 
  340.            to 1. However, fractions are difficult to use in a fixed point 
  341.            microprocessor so the KISS  TNC actually works with P values that 
  342.            are rescaled to the range 0 to  255.   To  avoid  confusion,  we  
  343.            will  use lower-case  p to mean the former (0-1) and upper-case
  344.            P whenever we mean the latter (0-255).
  345.  
  346.  
  347.  
  348.                                     July 14, 1990
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.            remains stable under heavy load.   See  references  [1]  through
  358.            [13] for details.
  359.  
  360.                 We believe that optimum p and SlotTime  values  could  be
  361.            computed  automatically.  This could be done by noting the chan-
  362.            nel occupancy and the length of the frames on the  channel.   We
  363.            are  proceeding with a simulation of the p-persistence algorithm
  364.            described here that we  hope  will  allow  us  to  construct  an
  365.            automatic algorithm for p and SlotTime selection.
  366.  
  367.                 We added p-persistence to the KISS TNC  because  it  was  a
  368.            convenient  opportunity to do so.  However, it is not inherently
  369.            associated with KISS nor with  new  protocols  such  as  TCP/IP.
  370.            Rather,  persistence is a channel access protocol that can yield
  371.            dramatic performance improvements regardless of the higher level
  372.            protocol  in  use;  we urge it be added to every TNC, whether or
  373.            not it supports KISS.
  374.  
  375.            7.  Implementation History
  376.  
  377.                 The original idea for a simplified host/TNC protocol is due
  378.            to Brian Lloyd, WB6RQN.  Phil Karn, KA9Q, organized the specifi-
  379.            cation and submitted an initial version on 6 August 1986.  As of
  380.            this writing, the following KISS TNC implementations exist:
  381.  
  382.  
  383.            TNC  type          Author                  Comments 
  384.  
  385.            TAPR TNC-2 & clones    Mike  Chepponis,  K3MC  First implementation,
  386.                                                           most widely used. 
  387.                                                           Exists in both 
  388.                                                           downloadable and 
  389.                                                           dedicated  ROM.
  390.            TAPR TNC-1 & clones    Marc Kaufman, WB6ECE    Both download and 
  391.                                                           dedicated ROM.   
  392.            VADCG  TNC             Mike Bruski, AJ9X       Dedicated ROM.   
  393.            AEA PK-232 & PK-87     Steve Stuart, N6IA      Integrated into 
  394.                                                           standard AEA firmware
  395.                                                           as  of  21 Jan 1987.
  396.  
  397.            The special commands "KISS ON" and "KISS OFF" (!) control entry 
  398.            into KISS mode.  
  399.  
  400.            Kantronics             Mike  Huslig             Integrated  into  
  401.                                                            standard Kantronics
  402.                                                            firmware as of July
  403.                                                            1987.
  404.  
  405.  
  406.                 The AEA and Kantronics implementations  are  noteworthy  in
  407.            that  the  KISS  functions  were  written  by  those vendors and
  408.            integrated into their standard  TNC  firmware.  Their  TNCs  can
  409.            operate  in  either  KISS  or  regular  AX.25  mode  without ROM
  410.            changes.  Since the TNC-1 and TNC-2 KISS versions  were  written
  411.            by  different  authors  than  the  original  AX.25 firmware, and
  412.            because the original source code for those  TNCs  was  not  made
  413.            available,  running KISS on these TNCs requires the installation
  414.            of nonstandard ROMs. Two ROMs are available for the  TNC-2.  One
  415.            contains "dedicated" KISS TNC code; the TNC operates only in the
  416.            KISS  mode.  The  "download"  version  contains  standard   N2WX
  417.            firmware with a bootstrap loader overlay. When the TNC is turned
  418.            on or reset, it executes the loader. The loader  will  accept  a
  419.            memory  image  in Intel Hex format, or it can be told to execute
  420.            the standard N2WX firmware  through  the  "H"[3]  command.   The
  421.  
  422.  
  423.  
  424.                                     July 14, 1990
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.            download version is handy for occasional KISS  operation,  while
  434.            the  dedicated  version is much more convenient for full-time or
  435.            demo KISS operation.
  436.  
  437.                 The code for the TNC-1 is also available in  both  download
  438.            and  dedicated  versions.  However,  at present the download ROM
  439.            contains only a bootstrap; the original ROMs must be put back in
  440.            to run the original TNC software.
  441.  
  442.            8.  Credits
  443.  
  444.                 The combined "Howie + downloader" ROM  for  the  TNC-2  was
  445.            contributed  by  WA7MXZ.  This document was carefully typeset by
  446.            Bob Hoffman, N3CVL.
  447.  
  448.  
  449.            9.  Bibliography
  450.  
  451.  
  452.            1.   Tanenbaum, Andrew S., "Computer  Networks"    pp.  288-292.
  453.                 Prentice-Hall  1981.
  454.  
  455.            2.   Tobagi, F. A.: "Random Access Techniques for Data Transmis-
  456.                 sion  over  Packet  Switched Radio Networks," Ph.D. thesis,
  457.                 Computer Science Department, UCLA, 1974.
  458.  
  459.            3.   Kleinrock, L., and Tobagi, F.:  "Random  Access  Techniques
  460.                 for Data Transmission over Packet-Switched Radio Channels,"
  461.                 Proc. NCC, pp. 187-201, 1975.
  462.  
  463.            4.   Tobagi, F. A., Gerla, M., Peebles, R.W., and Manning, E.G.:
  464.                 "Modeling  and  Measurement Techniques in Packet Communica-
  465.                 tions Networks," Proc.  IEEE, vol. 66, pp. 1423-1447,  Nov.
  466.                 1978.
  467.  
  468.            5.   Lam, S. S.: "Packet Switching in  a  Multiaccess  Broadcast
  469.                 Channel",  Ph.D. thesis, Computer Science Department, UCLA,
  470.                 1974.
  471.  
  472.            6.   Lam, S. S., and Kleinrock, L.: "Packet Switching in a  Mul-
  473.                 tiaccess  Broadcast  Channel:  Dynamic Control Procedures,"
  474.                 IEEE Trans. Commun., vol COM-23, pp. 891-904, Sept. 1975.
  475.  
  476.            7.   Lam, S. S.: "A Carrier Sense Multiple Access  Protocol  for
  477.                 Local  Networks,"  Comput. Networks, vol 4, pp. 21-32, Feb.
  478.                 1980
  479.  
  480.            8.   Tobagi, F. A.: "Multiaccess Protocols in Packet  Communica-
  481.                 tions  Systems,"  IEEE Trans. Commun., vol COM-28, pp. 468-
  482.                 488, April 1980c.
  483.  
  484.  
  485.  
  486.                                     July 14, 1990
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.            9.   Bertsekas, D., and Gallager, R.: "Data Networks", pp.  274-
  496.                 282 Prentice-Hall 1987.
  497.  
  498.            10.  Kahn, R. E., Gronemeyer, S. A., Burchfiel, J., and  Kungel-
  499.                 man,  R.  C.   "Advances in Packet Radio Technology," Proc.
  500.                 IEEE.  pp. 1468-1496.  1978.
  501.  
  502.            11.  Takagi, H.: "Analysis of Polling  Systems,"  Cambridge,  MA
  503.                 MIT Press 1986.
  504.  
  505.            12.  Tobagi, F. A., and Kleinrock, L. "Packet Switching in Radio
  506.                 Channels: Part II - The Hidden Terminal Problem in CSMA and
  507.                 Busy-Tone Solution," IEEE Trans. Commun.  COM-23 pp.  1417-
  508.                 1433.  1975.
  509.  
  510.            13.  Rivest, R. L.: "Network Control  by  Bayessian  Broadcast,"
  511.                 Report MIT/LCS/TM-285.  Cambridge, MA.  MIT, Laboratory for
  512.                 Computer Science.  1985.
  513.  
  514.            14.  Karn, P. and Lloyd, B.: "Link Level  Protocols  Revisited,"
  515.                 ARRL  Amateur  Radio  Fifth Computer Networking Conference,
  516.                 pp. 5.25-5.37, Orlando, 9 March 1986.
  517.  
  518.            15.  Karn, P., "Why Do We Even Need TNCs Anyway", Gateway,  vol.
  519.                 3 no. 2, September 5, 1986.
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.                                     July 14, 1990
  553.  
  554.  
  555.